package com.demo.domain;

import java.io.Serializable;

/**
 * Author: Alexey Tokan
 * Date: 27.07.12
 * Time: 10:32
 */
public class Contact implements Serializable{

    public final static String CONTACT = "contact";

    private String firstName;
    private String lastName;
    private String phone;
    private String email;
    private String photo;

    public Contact() {
    }

    public Contact(String firstName, String lastName, String phone, String email, String photo) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.phone = phone;
        this.email = email;
        this.photo = photo;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof Contact) {
            Contact contact = (Contact) o;
            // if fields is not null check if equals else check if both is null
            return ((firstName != null && firstName.equals(contact.firstName)) || firstName == contact.firstName)
                    && ((lastName != null && lastName.equals(contact.lastName)) || lastName == contact.lastName)
                    && ((phone != null && phone.equals(contact.phone)) || phone == contact.phone)
                    && ((email != null && email.equals(contact.email)) || email == contact.email)
                    && ((photo != null && photo.equals(contact.photo)) || photo == contact.photo);
        }
        return false;
    }

    private static final long serialVersionUID = 2;

}
